/*
package com.ruiyi.subway.service;

import com.google.common.collect.Sets;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.yuancore.vcs.common.exception.VcsBusinessException;
import com.yuancore.vcs.common.utils.PropertiesUtil;
import com.yuancore.vcs.dto.auth.RoleType;
import com.yuancore.vcs.dto.auth.User;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.*;

@Service
public class RoleService {

    private HashMap<RoleType, List<String>> resources;


    @PostConstruct
    public void initResources() throws VcsBusinessException {

        Properties properties = PropertiesUtil.loadClasspathProperties("vcs-role.properties");
        resources = new Gson().fromJson(properties.getProperty("user.roles"), new TypeToken<Map<RoleType, List<String>>>(){}.getType());
        if (resources == null) {
            throw new VcsBusinessException();
        } else {
            List<String> agencyManagers = resources.get(RoleType.AGENCY_MANAGER);
            List<String> managers = resources.get(RoleType.MANAGER);
            List<String> admins = resources.get(RoleType.ADMIN);
            if (agencyManagers != null) {
                if (managers == null) {
                    managers = agencyManagers;
                } else {
                    managers.addAll(agencyManagers);
                }

                resources.put(RoleType.MANAGER, managers);
            }
            if (managers != null) {
                if (admins == null) {
                    admins = managers;
                } else {
                    admins.addAll(managers);
                }

                resources.put(RoleType.ADMIN, admins);
            }
        }
    }

    public List<String> getRoleResource(RoleType type){
        return resources.get(type);
    }

    public boolean authRole(User user, String resource){
        if(user.getRoleName() != null){
            return resources.get(user.getRoleName()).contains(resource);
        }else{
            return false;
        }

    }

}
*/
